<%= form_for @task,
     :method => :post do |f|
 %>
<div class='new_task'>
  <h6>增加一项任务</h6>
  <dl>
    <dt></dt>
    <dd>
      <%= f.text_field :name, :class => :task_name %>
    </dd>
  </dl>
  <dl>
    <dt>该任务指派给谁?</dt>
    <dd>
      <%= f.select :executor_id, User.active.workmates.collect { |user| [user.nick_name, user.id]} %>
    </dd>
  </dl>
  <dl>
    <dt>何时到期？</dt>
    <dd>
      <%= f.text_field :due_on, :class => :date %>
      <script>
        $('#task_due_on').datepicker({
          showButtonPanel: true
        });
      </script>
    </dd>
  </dl>
  <dl>
    <dt></dt>
    <dd>
      <%= f.check_box :visible_scope, {}, 'everyone', 'only_myself'%> <%= label :task, :visible_scope, '让所有同事可以见到该任务' %>
    </dd>
  </dl>
  <dl>
    <dt>任务类型</dt>
    <dd id='task_type_by_input' class='task_type_by_input'>
    <%= f.text_field :type_name, :id => "text_task_type", :class => :task_type, :value => "提醒" %>
    <%= link_to_function '选择',"$('#task_type_by_select').show();$('#task_type_by_input').hide()", :title => '从已有的类型中挑选一项', :class => 'task_type_switch task_type_switch_from_select' %>
    </dd>
    <dd id='task_type_by_select' class='task_type_by_select'>
    <%=select_tag :sel_type_name, task_types, :class => :task_types%>
    <%= link_to_function '输入',"$('#task_type_by_input').show();$('#task_type_by_select').hide();$('#text_task_type').select()", :title => '没有合适的，还是我自己输入吧', :class => 'task_type_switch task_type_switch_from_input' %>
    <script type="text/javascript" charset="utf-8">
      $('#sel_type_name').change(function() {
        $('#text_task_type').val($(this).val());
      })
    </script>
    </dd>
  </dl>  
  <div class='clear'></div>
  <hr/>
  <dl>
    <dt></dt>
    <dd>
      <%= submit_tag '增加该任务' %>
    </dd>
  </dl>
</div>
<div class='clear'></div>
<%end%>